Example Program
Iterator Basics
Simple iterator functions.
File "iterator.cpp"
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 |
The metafunction Iterator returns the iterator type for a given container type.
| 8 | |
| 9 | |
| 10 |
The following lines show a loop through str in the standard library style:
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 |
Seqan offers an alternative style for accessing iterators that avoids operators.
Note that the functions goBegin and atEnd do net get str as arguments,
because it2 is a rooted iterator.
The following loop increments each character in str :
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 |
This is a reverse loop through str .
Note that goPrevious is called before the value of it2 is accessed,
because the end position of a container is the position behind the last item in the container:
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 |
Another (write only) way to access the value of an iterator is assignValue:
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 |
See
See Also
SeqAn - Sequence Analysis Library - www.seqan.de